package cn.stylefeng.guns.config.web;

/**
 * <b> 开启乐观锁
 * </b><br><br><i>Description</i> :
 * <br> Author : dxl
 * <br> Date : 2019/1/29 17:10
 */
import com.baomidou.mybatisplus.entity.GlobalConfiguration;
import com.baomidou.mybatisplus.mapper.ISqlInjector;
import com.baomidou.mybatisplus.mapper.LogicSqlInjector;
import com.baomidou.mybatisplus.plugins.OptimisticLockerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

@Configuration
public class MyBatisPlusConfiguration {

    //@Bean
    //@Primary
    //public ISqlInjector sqlInjector() {
    //    return new LogicSqlInjector();
    //}
    //@Bean
    //public GlobalConfiguration globalConfiguration() {
    //    GlobalConfiguration conf = new GlobalConfiguration(new LogicSqlInjector());
    //    conf.setLogicDeleteValue("-1");
    //    conf.setLogicNotDeleteValue("1");
    //    conf.setIdType(2);
    //    return conf;
    //}
    @Bean
    public OptimisticLockerInterceptor optimisticLockerInterceptor() {
        return new OptimisticLockerInterceptor();
    }
}
